/**
 * @Author: 九璃怀特 1599130621@qq.com
 * @Date: 2023-12-21 16:36:17
 * @LastEditors: 九璃怀特 1599130621@qq.com
 * @LastEditTime: 2023-12-29 14:49:35
 * @FilePath: \zxi-surface-manual\src\main.ts
 * @Description:
 */
import { createApp } from "vue";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import "element-plus/theme-chalk/dark/css-vars.css";
import "./style/reset.css";
import "./style/theme.less";
import BaseUI from "~/BaseUI";
import App from "./App.vue";

const initApp = async () => {
  console.log("init app");

  const app = createApp(App);
  app.use(ElementPlus).use(BaseUI).mount("#app");
};

if (window.electronAPI) {
  initApp();
  if (import.meta.env.MODE === "development") {
    // 开发环境监听F12切换调试工具
    window.addEventListener("keyup", (e) => {
      if (e.key === "F12" || e.key === "PageDown") {
        window.electronAPI.toggleDevTools();
      }
      if (e.key === "F5") {
        window.location.reload();
      }
    });
  }
} else if (window.plus) {
  // 目前的需求暂时不需要用plus
  initApp();
} else {
  document.addEventListener(
    "plusready",
    () => {
      initApp();
    },
    false
  );
}
